<!-- 提现 -->
<template>
	<div class="main">
		<!-- 标题 -->
		<div class="title flex flex-y flex-between">
			<h3>{{title}}</h3>
			<div class="right">
				<el-button
					v-loading="loading"
					@click="save()"
					class="right"
					type="primary"
					size="small">保存
				</el-button>
				<el-button class="right" size="small" @click="ifShow = !ifShow">变动日志</el-button>
			</div>
		</div>
		<!-- 内容 -->
		<div class="content">
			<div class="flex flex-y">
				<p>用户账户余额必须 ≥  </p>
				<ipt v-model="cash.paramValue" style="width:50px;" class="left10 right10"/>
				<p>元</p>
			</div>
			<div class="area">
				<h3 class="title">提现时间</h3>
				<div class="flex flex-y group">
					<label>砂锅号</label>
					<ipt v-model="money.paramValue" style="width:50px;" class="left5 right10"/>
					<p>号/月</p>
				</div>
				<div class="flex flex-y group">
					<label>砂锅用户</label>
					<el-select
						style="width:60px;margin:0 6px"
						v-model="t">
						<el-option
							v-for="item in list_user"
							:key="item.value"
							:label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
					<p>+</p>
					<ipt v-model="day" style="width:50px;margin-left:6px" class="right10"/>
					<p>天</p>
				</div>
				<div class="flex flex-y group">
					<label>生效时间</label>
					<el-date-picker
						style="margin:0 6px"
						v-model="date.paramValue"
						type="datetime"
						placeholder="选择日期"
						size="small"
						value-format="timestamp">
					</el-date-picker>
				</div>
			</div>
			<div class="area">
				<h3 class="title">提现费用</h3>
				<div class="flex flex-y group">
					<div class="flex flex-y">
						<p>砂锅号</p>
						<ipt v-model="cost.paramValue" style="width:50px;" class="left5 right10"/>
						<p class="right60">%</p>
					</div>
					<div class="flex flex-y">
						<p>单笔手续费</p>
						<ipt v-model="single.paramValue" style="width:50px;" class="left5 right10"/>
						<p>元</p>
					</div>
				</div>
				<div class="flex flex-y group">
					<div class="flex flex-y">
						<p>单笔限额</p>
						<ipt v-model="limit.paramValue" style="width:68px;" class="left5 right10"/>
						<p class="right60">元</p>
					</div>
					<div class="flex flex-y">
						<p>每日限额</p>
						<ipt v-model="everyday.paramValue" style="width:68px;" class="left5 right10"/>
						<p class="right60">元</p>
					</div>
					<div class="flex flex-y">
						<p>每月限额</p>
						<ipt v-model="everymonth.paramValue" style="width:68px;" class="left5 right10"/>
						<p>元</p>
					</div>
				</div>
			</div>
		</div>
		<!-- 变动日志 -->
		<el-dialog title="变动日志" :visible.sync="ifShow">
			<airlog query="withdraw" />
		</el-dialog>
	</div>
</template>

<script>
import txt from '@/components/public/input/input.vue'
import airlog from '@/pages/runManage/param/components/log.vue'
export default {
	props:["title","data"],
	components:{
		txt,
		airlog
	},
	data () {
		return {
			ifShow:false,
			loading:false,
			// 提现设置
			cash:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// 砂锅号
			money:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// T
			t:'T',
			// 天
			day:0,
			// merge
			merge:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// 日期
			date:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:'2020-11-11'
			},
			dateValue:"",
			// 费用 砂锅号
			cost:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// 单笔手续费
			single:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// 单笔限额
			limit:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// 每日
			everyday:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			// 每月
			everymonth:{
				uid:'',
				paramType:'withdraw',
				paramName:'',
				paramValue:0,
			},
			list_user:[
				{
					value:1,
					label:"T"
				},
				{
					value:2,
					label:"D"
				}
			],
		}
	},
	watch:{
		data(val){
			// 至少余额
			this.cash.uid = val.withdraw[0].uid;
			this.cash.paramType = val.withdraw[0].paramType;
			this.cash.paramName = val.withdraw[0].paramName;
			this.cash.paramValue = val.withdraw[0].paramValue;
			// 砂锅号
			this.money.uid = val.withdraw[1].uid;
			this.money.paramType = val.withdraw[1].paramType;
			this.money.paramName = val.withdraw[1].paramName;
			this.money.paramValue = val.withdraw[1].paramValue;
			// t + day
			this.t = val.withdraw[2].paramValue.substr(-1);
			this.day = val.withdraw[2].paramValue.substr(0,val.withdraw[2].paramValue.length-1);
			// merge
			this.merge.uid = val.withdraw[2].uid;
			this.merge.paramType = val.withdraw[2].paramType;
			this.merge.paramName = val.withdraw[2].paramName;
			this.merge.paramValue = val.withdraw[2].paramValue;
			// 日期
			this.date.uid = val.withdraw[3].uid;
			this.date.paramType = val.withdraw[3].paramType;
			this.date.paramName = val.withdraw[3].paramName;
			this.date.paramValue = val.withdraw[3].paramValue.length == 10?val.withdraw[3].paramValue*1000:val.withdraw[3].paramValue;
			// 费用 砂锅号
			this.cost.uid = val.withdraw[4].uid;
			this.cost.paramType = val.withdraw[4].paramType;
			this.cost.paramName = val.withdraw[4].paramName;
			this.cost.paramValue = val.withdraw[4].paramValue;
			// 单笔手续费
			this.single.uid = val.withdraw[5].uid;
			this.single.paramType = val.withdraw[5].paramType;
			this.single.paramName = val.withdraw[5].paramName;
			this.single.paramValue = val.withdraw[5].paramValue;
			// 单笔限额
			this.limit.uid = val.withdraw[6].uid;
			this.limit.paramType = val.withdraw[6].paramType;
			this.limit.paramName = val.withdraw[6].paramName;
			this.limit.paramValue = val.withdraw[6].paramValue;
			// 每日
			this.everyday.uid = val.withdraw[7].uid;
			this.everyday.paramType = val.withdraw[7].paramType;
			this.everyday.paramName = val.withdraw[7].paramName;
			this.everyday.paramValue = val.withdraw[7].paramValue;
			// 每月
			this.everymonth.uid = val.withdraw[8].uid;
			this.everymonth.paramType = val.withdraw[8].paramType;
			this.everymonth.paramName = val.withdraw[8].paramName;
			this.everymonth.paramValue = val.withdraw[8].paramValue;
		}
	},
	methods:{
		save:function(){
			this.loading = true;
			// 处理数据
			let arr = [];
			this.merge.paramValue = this.day + this.t; //处理时间
			arr.push(this.cash,this.money,this.merge,this.date,this.cost,this.single,this.limit,this.everyday,this.everymonth);
			console.log(arr);
			// 请求
			HTTP('financeSet_save', arr)
			.then(res=>{
				this.loading = false;
				if(res.code == 200){
					this.common.msg('保存成功');
				}
				else{
					this.common.msg(res.msg,'error');
				}
			})
		}
	},
	mounted(){

	}
}
</script>

<style lang="scss" scoped>
	/deep/ .el-input__inner{
		text-align: center;
		height: 33px;
		line-height: 33px;
	}
	.main{
		padding: 25px 30px;
		//标题
		.title{
			position: relative;
			h3{
				font-size: 16px;
			}
			h3:before{
				position: absolute;
				left: -16px;
				top: 5px;
				content:'\25CF';
				color: $blue;
			}
		}
	}
	.content{
		margin-top: 40px;
		.area{
			.title{
				padding: 44px 0 4px 0;
				font-size: 16px;
				color: $blue;
			}
			.group{
				label{
					display: block;
					width: 66px;
					text-align: left;
				}
				margin: 14px 0;
			}
			.right60{
				margin-right: 60px;
			}
		}
	}
</style>
